home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / autose1g / frmnewga.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-06-24  |  32.9 KB  |  1,114 lines

  1. VERSION 5.00
  2. Begin VB.Form frmNewGame 
  3.    AutoRedraw      =   -1  'True
  4.    BackColor       =   &H00000000&
  5.    BorderStyle     =   0  'None
  6.    Caption         =   "                                    Setup A New Game"
  7.    ClientHeight    =   5655
  8.    ClientLeft      =   45
  9.    ClientTop       =   930
  10.    ClientWidth     =   9465
  11.    ControlBox      =   0   'False
  12.    Icon            =   "FRMNEWGA.frx":0000
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    PaletteMode     =   1  'UseZOrder
  16.    ScaleHeight     =   5655
  17.    ScaleWidth      =   9465
  18.    ShowInTaskbar   =   0   'False
  19.    Begin VB.CommandButton cmdExit 
  20.       Caption         =   "E&xit Game"
  21.       Height          =   330
  22.       Left            =   4455
  23.       TabIndex        =   22
  24.       Top             =   5040
  25.       Width           =   1200
  26.    End
  27.    Begin VB.PictureBox picChooseSector 
  28.       BackColor       =   &H00000000&
  29.       Height          =   1335
  30.       Left            =   5595
  31.       ScaleHeight     =   1275
  32.       ScaleWidth      =   1515
  33.       TabIndex        =   6
  34.       Top             =   2655
  35.       Width           =   1575
  36.       Begin VB.CommandButton cmdChoice 
  37.          Caption         =   "X"
  38.          BeginProperty Font 
  39.             Name            =   "MS Sans Serif"
  40.             Size            =   8.25
  41.             Charset         =   0
  42.             Weight          =   700
  43.             Underline       =   0   'False
  44.             Italic          =   0   'False
  45.             Strikethrough   =   0   'False
  46.          EndProperty
  47.          Height          =   315
  48.          Index           =   3
  49.          Left            =   1200
  50.          TabIndex        =   10
  51.          Top             =   960
  52.          Width           =   315
  53.       End
  54.       Begin VB.CommandButton cmdChoice 
  55.          Caption         =   "X"
  56.          BeginProperty Font 
  57.             Name            =   "MS Sans Serif"
  58.             Size            =   8.25
  59.             Charset         =   0
  60.             Weight          =   700
  61.             Underline       =   0   'False
  62.             Italic          =   0   'False
  63.             Strikethrough   =   0   'False
  64.          EndProperty
  65.          Height          =   315
  66.          Index           =   2
  67.          Left            =   0
  68.          TabIndex        =   9
  69.          Top             =   960
  70.          Width           =   315
  71.       End
  72.       Begin VB.CommandButton cmdChoice 
  73.          Caption         =   "X"
  74.          BeginProperty Font 
  75.             Name            =   "MS Sans Serif"
  76.             Size            =   8.25
  77.             Charset         =   0
  78.             Weight          =   700
  79.             Underline       =   0   'False
  80.             Italic          =   0   'False
  81.             Strikethrough   =   0   'False
  82.          EndProperty
  83.          Height          =   315
  84.          Index           =   1
  85.          Left            =   1200
  86.          TabIndex        =   8
  87.          Top             =   0
  88.          Width           =   315
  89.       End
  90.       Begin VB.CommandButton cmdChoice 
  91.          Caption         =   "X"
  92.          BeginProperty Font 
  93.             Name            =   "MS Sans Serif"
  94.             Size            =   8.25
  95.             Charset         =   0
  96.             Weight          =   700
  97.             Underline       =   0   'False
  98.             Italic          =   0   'False
  99.             Strikethrough   =   0   'False
  100.          EndProperty
  101.          Height          =   315
  102.          Index           =   0
  103.          Left            =   0
  104.          TabIndex        =   7
  105.          Top             =   0
  106.          Width           =   315
  107.       End
  108.    End
  109.    Begin VB.Frame fraSelect 
  110.       BackColor       =   &H00000000&
  111.       Caption         =   "Choose Home Planet"
  112.       BeginProperty Font 
  113.          Name            =   "MS Sans Serif"
  114.          Size            =   9.75
  115.          Charset         =   0
  116.          Weight          =   700
  117.          Underline       =   0   'False
  118.          Italic          =   0   'False
  119.          Strikethrough   =   0   'False
  120.       EndProperty
  121.       ForeColor       =   &H0000FFFF&
  122.       Height          =   1800
  123.       Left            =   2685
  124.       TabIndex        =   12
  125.       Top             =   2340
  126.       Width           =   4725
  127.       Begin VB.TextBox txtNamePlanet 
  128.          BackColor       =   &H00000000&
  129.          BeginProperty Font 
  130.             Name            =   "MS Sans Serif"
  131.             Size            =   8.25
  132.             Charset         =   0
  133.             Weight          =   700
  134.             Underline       =   0   'False
  135.             Italic          =   0   'False
  136.             Strikethrough   =   0   'False
  137.          EndProperty
  138.          ForeColor       =   &H0000FF00&
  139.          Height          =   330
  140.          Left            =   540
  141.          TabIndex        =   21
  142.          Top             =   1245
  143.          Width           =   1575
  144.       End
  145.       Begin VB.Label lblPlanetName 
  146.          Appearance      =   0  'Flat
  147.          BackColor       =   &H000000C0&
  148.          BackStyle       =   0  'Transparent
  149.          Caption         =   "Name Your Home Planet:"
  150.          BeginProperty Font 
  151.             Name            =   "MS Sans Serif"
  152.             Size            =   8.25
  153.             Charset         =   0
  154.             Weight          =   700
  155.             Underline       =   0   'False
  156.             Italic          =   0   'False
  157.             Strikethrough   =   0   'False
  158.          EndProperty
  159.          ForeColor       =   &H0000FF00&
  160.          Height          =   255
  161.          Left            =   195
  162.          TabIndex        =   15
  163.          Top             =   990
  164.          Width           =   2355
  165.       End
  166.       Begin VB.Label Label1 
  167.          BackColor       =   &H000000C0&
  168.          BackStyle       =   0  'Transparent
  169.          Caption         =   "Choose sector - Player 2 will start in the opposite corner"
  170.          BeginProperty Font 
  171.             Name            =   "MS Sans Serif"
  172.             Size            =   8.25
  173.             Charset         =   0
  174.             Weight          =   700
  175.             Underline       =   0   'False
  176.             Italic          =   0   'False
  177.             Strikethrough   =   0   'False
  178.          EndProperty
  179.          ForeColor       =   &H0000FF00&
  180.          Height          =   435
  181.          Left            =   180
  182.          TabIndex        =   13
  183.          Top             =   360
  184.          Width           =   2595
  185.       End
  186.    End
  187.    Begin VB.Frame fraInfo 
  188.       BackColor       =   &H00000000&
  189.       Caption         =   "Player 1 Setup"
  190.       BeginProperty Font 
  191.          Name            =   "MS Sans Serif"
  192.          Size            =   9.75
  193.          Charset         =   0
  194.          Weight          =   700
  195.          Underline       =   0   'False
  196.          Italic          =   0   'False
  197.          Strikethrough   =   0   'False
  198.       EndProperty
  199.       ForeColor       =   &H0000FFFF&
  200.       Height          =   2055
  201.       Left            =   2670
  202.       TabIndex        =   11
  203.       Top             =   135
  204.       Width           =   3015
  205.       Begin VB.TextBox txtResources 
  206.          Alignment       =   1  'Right Justify
  207.          Appearance      =   0  'Flat
  208.          BackColor       =   &H00000000&
  209.          BeginProperty Font 
  210.             Name            =   "MS Sans Serif"
  211.             Size            =   8.25
  212.             Charset         =   0
  213.             Weight          =   700
  214.             Underline       =   0   'False
  215.             Italic          =   0   'False
  216.             Strikethrough   =   0   'False
  217.          EndProperty
  218.          ForeColor       =   &H0000FF00&
  219.          Height          =   285
  220.          Left            =   1380
  221.          TabIndex        =   20
  222.          Text            =   "15"
  223.          Top             =   1170
  224.          Width           =   615
  225.       End
  226.       Begin VB.TextBox txtTroops 
  227.          Alignment       =   1  'Right Justify
  228.          Appearance      =   0  'Flat
  229.          BackColor       =   &H00000000&
  230.          BeginProperty Font 
  231.             Name            =   "MS Sans Serif"
  232.             Size            =   8.25
  233.             Charset         =   0
  234.             Weight          =   700
  235.             Underline       =   0   'False
  236.             Italic          =   0   'False
  237.             Strikethrough   =   0   'False
  238.          EndProperty
  239.          ForeColor       =   &H0000FF00&
  240.          Height          =   285
  241.          Left            =   1380
  242.          TabIndex        =   18
  243.          Text            =   "10"
  244.          Top             =   1515
  245.          Width           =   615
  246.       End
  247.       Begin VB.TextBox txtPlayer1Name 
  248.          BackColor       =   &H00000000&
  249.          BeginProperty Font 
  250.             Name            =   "MS Sans Serif"
  251.             Size            =   9.75
  252.             Charset         =   0
  253.             Weight          =   700
  254.             Underline       =   0   'False
  255.             Italic          =   0   'False
  256.             Strikethrough   =   0   'False
  257.          EndProperty
  258.          ForeColor       =   &H0000FF00&
  259.          Height          =   360
  260.          Left            =   1080
  261.          TabIndex        =   1
  262.          Top             =   375
  263.          Width           =   1620
  264.       End
  265.       Begin VB.Label lblResources 
  266.          BackColor       =   &H000000C0&
  267.          BackStyle       =   0  'Transparent
  268.          Caption         =   "Resources:"
  269.          BeginProperty Font 
  270.             Name            =   "MS Sans Serif"
  271.             Size            =   8.25
  272.             Charset         =   0
  273.             Weight          =   700
  274.             Underline       =   0   'False
  275.             Italic          =   0   'False
  276.             Strikethrough   =   0   'False
  277.          EndProperty
  278.          ForeColor       =   &H0000FF00&
  279.          Height          =   255
  280.          Left            =   180
  281.          TabIndex        =   19
  282.          Top             =   1200
  283.          Width           =   1035
  284.       End
  285.       Begin VB.Label lblTroops 
  286.          Appearance      =   0  'Flat
  287.          BackColor       =   &H000000C0&
  288.          BackStyle       =   0  'Transparent
  289.          Caption         =   "Troops:"
  290.          BeginProperty Font 
  291.             Name            =   "MS Sans Serif"
  292.             Size            =   8.25
  293.             Charset         =   0
  294.             Weight          =   700
  295.             Underline       =   0   'False
  296.             Italic          =   0   'False
  297.             Strikethrough   =   0   'False
  298.          EndProperty
  299.          ForeColor       =   &H0000FF00&
  300.          Height          =   315
  301.          Left            =   180
  302.          TabIndex        =   17
  303.          Top             =   1530
  304.          Width           =   735
  305.       End
  306.       Begin VB.Label lblInitialValues 
  307.          Appearance      =   0  'Flat
  308.          BackColor       =   &H80000005&
  309.          BackStyle       =   0  'Transparent
  310.          Caption         =   "Initial Settings:"
  311.          BeginProperty Font 
  312.             Name            =   "MS Sans Serif"
  313.             Size            =   9.75
  314.             Charset         =   0
  315.             Weight          =   700
  316.             Underline       =   0   'False
  317.             Italic          =   0   'False
  318.             Strikethrough   =   0   'False
  319.          EndProperty
  320.          ForeColor       =   &H80000008&
  321.          Height          =   330
  322.          Left            =   150
  323.          TabIndex        =   16
  324.          Top             =   810
  325.          Width           =   1635
  326.       End
  327.       Begin VB.Label Label2 
  328.          BackColor       =   &H000000C0&
  329.          BackStyle       =   0  'Transparent
  330.          Caption         =   "Name:"
  331.          BeginProperty Font 
  332.             Name            =   "MS Sans Serif"
  333.             Size            =   9.75
  334.             Charset         =   0
  335.             Weight          =   700
  336.             Underline       =   0   'False
  337.             Italic          =   0   'False
  338.             Strikethrough   =   0   'False
  339.          EndProperty
  340.          ForeColor       =   &H0000FF00&
  341.          Height          =   315
  342.          Left            =   180
  343.          TabIndex        =   14
  344.          Top             =   420
  345.          Width           =   795
  346.       End
  347.    End
  348.    Begin VB.CommandButton cmdStartGame 
  349.       Caption         =   "&OK"
  350.       Default         =   -1  'True
  351.       Enabled         =   0   'False
  352.       Height          =   330
  353.       Left            =   4455
  354.       TabIndex        =   5
  355.       Top             =   4500
  356.       Width           =   1200
  357.    End
  358.    Begin VB.Frame fraDifficulty 
  359.       BackColor       =   &H00000000&
  360.       Caption         =   "Galaxy Size:"
  361.       BeginProperty Font 
  362.          Name            =   "MS Sans Serif"
  363.          Size            =   9.75
  364.          Charset         =   0
  365.          Weight          =   700
  366.          Underline       =   0   'False
  367.          Italic          =   0   'False
  368.          Strikethrough   =   0   'False
  369.       EndProperty
  370.       ForeColor       =   &H0000FFFF&
  371.       Height          =   2055
  372.       Left            =   5775
  373.       TabIndex        =   0
  374.       Top             =   135
  375.       Width           =   1695
  376.       Begin VB.OptionButton optHard 
  377.          BackColor       =   &H00000000&
  378.          Caption         =   "Large (50)"
  379.          BeginProperty Font 
  380.             Name            =   "MS Sans Serif"
  381.             Size            =   8.25
  382.             Charset         =   0
  383.             Weight          =   700
  384.             Underline       =   0   'False
  385.             Italic          =   0   'False
  386.             Strikethrough   =   0   'False
  387.          EndProperty
  388.          ForeColor       =   &H0000FF00&
  389.          Height          =   375
  390.          Left            =   150
  391.          TabIndex        =   4
  392.          Top             =   1335
  393.          Width           =   1350
  394.       End
  395.       Begin VB.OptionButton optMedium 
  396.          BackColor       =   &H00000000&
  397.          Caption         =   "Medium (40)"
  398.          BeginProperty Font 
  399.             Name            =   "MS Sans Serif"
  400.             Size            =   8.25
  401.             Charset         =   0
  402.             Weight          =   700
  403.             Underline       =   0   'False
  404.             Italic          =   0   'False
  405.             Strikethrough   =   0   'False
  406.          EndProperty
  407.          ForeColor       =   &H0000FF00&
  408.          Height          =   375
  409.          Left            =   150
  410.          TabIndex        =   3
  411.          Top             =   885
  412.          Width           =   1380
  413.       End
  414.       Begin VB.OptionButton optEasy 
  415.          BackColor       =   &H00000000&
  416.          Caption         =   "Small (30)"
  417.          BeginProperty Font 
  418.             Name            =   "MS Sans Serif"
  419.             Size            =   8.25
  420.             Charset         =   0
  421.             Weight          =   700
  422.             Underline       =   0   'False
  423.             Italic          =   0   'False
  424.             Strikethrough   =   0   'False
  425.          EndProperty
  426.          ForeColor       =   &H0000FF00&
  427.          Height          =   375
  428.          Left            =   150
  429.          TabIndex        =   2
  430.          Top             =   435
  431.          Value           =   -1  'True
  432.          Width           =   1245
  433.       End
  434.    End
  435. Attribute VB_Name = "frmNewGame"
  436. Attribute VB_GlobalNameSpace = False
  437. Attribute VB_Creatable = False
  438. Attribute VB_PredeclaredId = True
  439. Attribute VB_Exposed = False
  440. Option Explicit
  441. Dim EasyResources, EasyTroops
  442. Dim MedResources, MedTroops
  443. Dim HardResources, HardTroops
  444. 'for the galaxy size version:
  445. Dim SmallResources, SmallTroops
  446. Dim LargeResources, LargeTroops
  447. Public Counter As Integer   'to keep track of length of player name
  448. Public SectorChoice As Integer 'to set starting home planet sectors
  449. Private Sub cmdChoice_Click(Index As Integer)
  450. 'player chooses home planet, other player gets opposite corner
  451. 'also sets planet's owner
  452. Select Case Index
  453. Case 0
  454.     SectorChoice = 0
  455. Case 1
  456.     SectorChoice = 1
  457. Case 2
  458.     SectorChoice = 2
  459. Case 3
  460.     SectorChoice = 3
  461. End Select
  462. If SectorChoice = 0 Then
  463.     Player(Current).HomePlanet = 0
  464.     Planet(0).Owner = Current
  465.     Player(Other).HomePlanet = 49
  466.     Planet(49).Owner = Other
  467.     'set other planets neutral
  468.     Planet(9).Owner = Neutral
  469.     Planet(40).Owner = Neutral
  470. ElseIf SectorChoice = 1 Then
  471.     Player(Current).HomePlanet = 9
  472.     Planet(9).Owner = Current
  473.     Player(Other).HomePlanet = 40
  474.     Planet(40).Owner = Other
  475.     'neutral
  476.     Planet(0).Owner = Neutral
  477.     Planet(49).Owner = Neutral
  478. ElseIf SectorChoice = 2 Then
  479.     Player(Current).HomePlanet = 40
  480.     Planet(40).Owner = Current
  481.     Player(Other).HomePlanet = 9
  482.     Planet(9).Owner = Other
  483.     'neutral
  484.     Planet(0).Owner = Neutral
  485.     Planet(49).Owner = Neutral
  486. ElseIf SectorChoice = 3 Then
  487.     Player(Current).HomePlanet = 49
  488.     Planet(49).Owner = Current
  489.     Player(Other).HomePlanet = 0
  490.     Planet(0).Owner = Other
  491.     Planet(9).Owner = Neutral
  492.     Planet(40).Owner = Neutral
  493. End If
  494. 'after selecting a starting sector,
  495. 'OK button is enabled
  496. cmdStartGame.Enabled = True
  497. cmdStartGame.SetFocus
  498. End Sub
  499. Private Sub cmdExit_Click()
  500. PlaySoundEffect "Quiet"
  501. If MsgBox("Are you sure?", vbYesNo + vbQuestion, "Exiting Game") = vbYes Then
  502.     PlaySoundEffect "Abort"
  503.     'deregister help file
  504.     QuitHelp
  505.     End
  506. End If
  507. End Sub
  508. Private Sub cmdStartGame_Click()
  509. 'force player 1 to choose a name
  510. If txtPlayer1Name.Text = "" Then
  511.     PlaySoundEffect "Quiet"
  512.     MsgBox "You must choose a name", vbOKOnly + vbExclamation, "Setup Error"
  513.     txtPlayer1Name.SetFocus
  514.     Exit Sub
  515. End If
  516. If GalaxySize = 30 Then
  517.    'goto procedure to reset homeplanets
  518.    ResetforSmallGalaxy
  519. End If
  520. 'update player stats
  521. With Player(Current)
  522.     .Name = txtPlayer1Name.Text
  523.     .NumTroops = Val(txtTroops.Text)
  524.     .NumAssaultTroops = 0
  525.     .NumResources = Val(txtResources.Text) - 5
  526.     .NumPlanets = 1
  527. End With
  528. With Player(Other)
  529. .NumTroops = Val(txtTroops.Text)
  530. .NumAssaultTroops = 0
  531. .NumResources = Val(txtResources.Text) - 5
  532. .NumPlanets = 1
  533. End With
  534. 'Update boolean values for ships
  535. Dim i As Integer
  536. For i = 0 To 1
  537.    Player(i).Ship(i).Launched = False
  538.         
  539. 'set homeplanet name if player does not
  540. If txtNamePlanet = "" Then
  541.     'select one of 5 random names
  542.     Dim Q As Integer
  543.     Q = Int(Rnd * 5) + 1
  544.     Select Case Q
  545.     Case 1
  546.         Planet(Player(Current).HomePlanet).Name = "Glath"
  547.     Case 2
  548.         Planet(Player(Current).HomePlanet).Name = "Pedantak"
  549.     Case 3
  550.         Planet(Player(Current).HomePlanet).Name = "Ritalin IV"
  551.     Case 4
  552.         Planet(Player(Current).HomePlanet).Name = "Belvantas"
  553.     Case 5
  554.         Planet(Player(Current).HomePlanet).Name = "Alt'ngaio"
  555.     End Select
  556.     Planet(Player(Current).HomePlanet).Name = txtNamePlanet.Text
  557. End If
  558. 'default player 2 home name
  559. Planet(Player(Other).HomePlanet).Name = "Player2Home"
  560. 'update homeplanet troops
  561. Planet(Player(Current).HomePlanet).Troops = Val(txtTroops.Text)
  562. Planet(Player(Other).HomePlanet).Troops = Val(txtTroops.Text)
  563. Planet(Player(Other).HomePlanet).AssaultTroops = 0
  564. 'update homeplanet resources
  565. Planet(Player(Current).HomePlanet).Resources = 5
  566. Planet(Player(Other).HomePlanet).Resources = 5
  567. 'update homeplanet combatstrength (default of 5)
  568. Dim X, Y
  569. X = Player(Current).HomePlanet
  570. Y = Player(Other).HomePlanet
  571. SetCombatStrength (X)
  572. SetCombatStrength (Y)
  573. 'adjust resources around home planets so players don't
  574. 'get screwed surrounded by planets with only 1 resource
  575. AdjustResources
  576. 'start the game
  577. PlaySoundEffect "Ambient1"
  578. frmGameScreen.Show
  579. Me.Hide
  580. End Sub
  581. Private Sub Form_Activate()
  582. DrawStars
  583. 'clear player name etc - without this, names from last
  584. 'game started could appear
  585. txtPlayer1Name.Text = ""
  586. txtNamePlanet.Text = ""
  587. cmdStartGame.Enabled = False
  588. End Sub
  589. Private Sub Form_Load()
  590. 'set player one as the first player
  591. Current = 0
  592. Other = 1
  593. TurnNumber = 1
  594. 'initialize difficulty values
  595. EasyResources = 25
  596. EasyTroops = 15
  597. MedResources = 15
  598. MedTroops = 15
  599. HardResources = 10
  600. HardTroops = 10
  601. 'Large is the default
  602. txtResources.Text = Str(HardResources)
  603. txtTroops.Text = Str(HardTroops)
  604. GalaxySize = 50
  605. optHard.Value = True
  606. '***set default value for GameNumber, otherwise it would be zero and cause an error
  607. GameNumber = 1
  608. '***clear messages and player 2 name, otherwise may 'leak' from last played game
  609. IncomingMessage = ""
  610. Player(0).Name = ""
  611. Player(1).Name = ""
  612. 'initialize planet info
  613. InitializePlanets
  614. 'set up alien-held planets
  615. SetupAliens
  616. End Sub
  617. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  618. 'do nothing
  619. Cancel = 1
  620. End Sub
  621. Private Sub optEasy_Click()
  622. 'Set easy values
  623. txtResources.Text = Str(EasyResources)
  624. txtTroops.Text = Str(EasyTroops)
  625. GalaxySize = 30
  626. End Sub
  627. Private Sub optHard_Click()
  628. 'set hard values
  629. txtResources.Text = Str(HardResources)
  630. txtTroops.Text = Str(HardTroops)
  631. GalaxySize = 50
  632. End Sub
  633. Private Sub optMedium_Click()
  634. 'set medium values
  635. txtResources.Text = Str(MedResources)
  636. txtTroops.Text = Str(MedTroops)
  637. GalaxySize = 40
  638. End Sub
  639. Private Sub txtNamePlanet_GotFocus()
  640. txtNamePlanet.Text = ""
  641. End Sub
  642. Private Sub txtPlayer1Name_GotFocus()
  643. txtPlayer1Name.Text = ""
  644. End Sub
  645. Private Sub txtPlayer1Name_KeyDown(KeyCode As Integer, Shift As Integer)
  646. 'limit player name to 12 characters
  647. If Counter > 12 Then
  648.     KeyCode = 0
  649. End If
  650. End Sub
  651. Private Sub txtPlayer1Name_KeyPress(KeyAscii As Integer)
  652. 'disallow certain keys
  653. 'Note: the backspace key erases the contents of the player name text box
  654. Select Case KeyAscii
  655.     Case 8
  656.         'backspace
  657.         txtPlayer1Name.Text = ""
  658.         Counter = 0
  659.     Case 32
  660.         'space bar
  661.         Counter = Counter + 1
  662.         If Counter > 14 Then
  663.             KeyAscii = 0
  664.             Beep
  665.         End If
  666.     Case Else
  667.         Counter = Counter + 1
  668.         If Counter > 14 Then
  669.            KeyAscii = 0
  670.            Beep
  671.         End If
  672. End Select
  673. End Sub
  674. Private Sub txtResources_KeyDown(KeyCode As Integer, Shift As Integer)
  675. 'disallow input
  676. KeyCode = 0
  677. End Sub
  678. Private Sub txtResources_KeyPress(KeyAscii As Integer)
  679. 'disallow input
  680. KeyAscii = 0
  681. End Sub
  682. Private Sub txtTroops_KeyDown(KeyCode As Integer, Shift As Integer)
  683. 'disallow input
  684. KeyCode = 0
  685. End Sub
  686. Private Sub txtTroops_KeyPress(KeyAscii As Integer)
  687. 'disallow input
  688. KeyAscii = 0
  689. End Sub
  690. Public Sub SetupAliens()
  691. 'set up 3 alien-held planets - they expand later in the game...
  692. Dim AlienPlanet1
  693. Dim AlienPlanet2
  694. Dim AlienPlanet3
  695. Dim troops1, troops2, troops3
  696. Randomize
  697. AlienPlanet1 = Int(Rnd * 5) + 12
  698. AlienPlanet2 = Int(Rnd * 5) + 21
  699. AlienPlanet3 = Int(Rnd * 5) + 34
  700. With Planet(AlienPlanet1)
  701.     .Owner = Alien
  702.     .Troops = Int(Rnd * 8) + 2
  703.     .Resources = Int(Rnd * 2) + 1
  704. End With
  705. 'call procedure from Declare.bas
  706. SetCombatStrength (AlienPlanet1)
  707. With Planet(AlienPlanet2)
  708.     .Owner = Alien
  709.     .Troops = Int(Rnd * 8) + 2
  710.     .Resources = Int(Rnd * 2) + 1
  711. End With
  712. SetCombatStrength (AlienPlanet2)
  713. With Planet(AlienPlanet3)
  714.     .Owner = Alien
  715.     .Troops = Int(Rnd * 8) + 2
  716.     .Resources = Int(Rnd * 2) + 1
  717. End With
  718. SetCombatStrength (AlienPlanet3)
  719. End Sub
  720. Public Sub ResetforSmallGalaxy()
  721. 'hide some of the planets if player 1 chooses a small galaxy
  722. If SectorChoice = 0 Then
  723.     Player(Current).HomePlanet = 11
  724.     Planet(11).Owner = Current
  725.     Player(Other).HomePlanet = 48
  726.     Planet(48).Owner = Other
  727.     'set original planets to neutral
  728.     Planet(0).Owner = Neutral
  729.     Planet(49).Owner = Neutral
  730.     Planet(9).Owner = Neutral
  731.     Planet(40).Owner = Neutral
  732.       
  733. ElseIf SectorChoice = 1 Then
  734.     Player(Current).HomePlanet = 18
  735.     Planet(18).Owner = Current
  736.     Player(Other).HomePlanet = 32
  737.     Planet(32).Owner = Other
  738.     'set planets to neutral
  739.     Planet(0).Owner = Neutral
  740.     Planet(49).Owner = Neutral
  741.     Planet(9).Owner = Neutral
  742.     Planet(40).Owner = Neutral
  743. ElseIf SectorChoice = 2 Then
  744.     Player(Current).HomePlanet = 32
  745.     Planet(32).Owner = Current
  746.     Player(Other).HomePlanet = 18
  747.     Planet(18).Owner = Other
  748.     'neutral
  749.     Planet(0).Owner = Neutral
  750.     Planet(49).Owner = Neutral
  751.     Planet(9).Owner = Neutral
  752.     Planet(40).Owner = Neutral
  753. ElseIf SectorChoice = 3 Then
  754.     Player(Current).HomePlanet = 48
  755.     Planet(48).Owner = Current
  756.     Player(Other).HomePlanet = 11
  757.     Planet(11).Owner = Other
  758.     'neutral
  759.     Planet(9).Owner = Neutral
  760.     Planet(40).Owner = Neutral
  761.     Planet(0).Owner = Neutral
  762.     Planet(49).Owner = Neutral
  763. End If
  764. End Sub
  765. Public Sub AdjustResources()
  766. '**to readjust the randomly assigned values, to balance play
  767. Select Case Player(Current).HomePlanet
  768. Case 0
  769.     'if any 1's around either homeplanet, change to 2's
  770.     'current player's surrounding planets:
  771.     If Planet(1).Resources = 1 Then Planet(1).Resources = 2
  772.     If Planet(2).Resources = 1 Then Planet(2).Resources = 2
  773.     If Planet(10).Resources = 1 Then Planet(10).Resources = 2
  774.     If Planet(11).Resources = 1 Then Planet(11).Resources = 2
  775.     'other player's surrounding planets:
  776.     If Planet(37).Resources = 1 Then Planet(37).Resources = 2
  777.     If Planet(39).Resources = 1 Then Planet(39).Resources = 2
  778.     If Planet(47).Resources = 1 Then Planet(47).Resources = 2
  779.     If Planet(48).Resources = 1 Then Planet(48).Resources = 2
  780. Case 9
  781.     'current player:
  782.     If Planet(7).Resources = 1 Then Planet(7).Resources = 2
  783.     If Planet(8).Resources = 1 Then Planet(8).Resources = 2
  784.     If Planet(18).Resources = 1 Then Planet(18).Resources = 2
  785.     If Planet(19).Resources = 1 Then Planet(19).Resources = 2
  786.     'other player:
  787.     If Planet(31).Resources = 1 Then Planet(31).Resources = 2
  788.     If Planet(32).Resources = 1 Then Planet(32).Resources = 2
  789.     If Planet(41).Resources = 1 Then Planet(41).Resources = 2
  790.     If Planet(42).Resources = 1 Then Planet(42).Resources = 2
  791. Case 40
  792.     'current player:
  793.     If Planet(31).Resources = 1 Then Planet(31).Resources = 2
  794.     If Planet(32).Resources = 1 Then Planet(32).Resources = 2
  795.     If Planet(41).Resources = 1 Then Planet(41).Resources = 2
  796.     If Planet(42).Resources = 1 Then Planet(42).Resources = 2
  797.     'other player:
  798.     If Planet(7).Resources = 1 Then Planet(7).Resources = 2
  799.     If Planet(8).Resources = 1 Then Planet(8).Resources = 2
  800.     If Planet(18).Resources = 1 Then Planet(18).Resources = 2
  801.     If Planet(19).Resources = 1 Then Planet(19).Resources = 2
  802. Case 49
  803.     If Planet(37).Resources = 1 Then Planet(37).Resources = 2
  804.     If Planet(39).Resources = 1 Then Planet(39).Resources = 2
  805.     If Planet(47).Resources = 1 Then Planet(47).Resources = 2
  806.     If Planet(48).Resources = 1 Then Planet(48).Resources = 2
  807.     'other player:
  808.     If Planet(1).Resources = 1 Then Planet(1).Resources = 2
  809.     If Planet(2).Resources = 1 Then Planet(2).Resources = 2
  810.     If Planet(10).Resources = 1 Then Planet(10).Resources = 2
  811.     If Planet(11).Resources = 1 Then Planet(11).Resources = 2
  812. Case Else
  813.     'do nothing - player playing in small galaxy
  814. End Select
  815. End Sub
  816. Public Sub DrawStars()
  817. Randomize
  818. 'draw white stars on the screen
  819. Dim a, X, Y
  820. For a = 1 To 400
  821.     X = Int(Rnd * Me.ScaleWidth)
  822.     Y = Int(Rnd * Me.ScaleHeight)
  823.     Me.PSet (X, Y), vbWhite
  824. Next a
  825. 'draw dark grey stars
  826. Dim grey
  827. grey = &H808080
  828. For a = 1 To 300
  829.     X = Int(Rnd * Me.ScaleWidth)
  830.     Y = Int(Rnd * Me.ScaleHeight)
  831.     Me.PSet (X, Y), grey
  832. Next a
  833. 'draw some blue stars
  834. Dim blue
  835. blue = &H800000
  836. For a = 1 To 200
  837.     X = Int(Rnd * Me.ScaleWidth)
  838.     Y = Int(Rnd * Me.ScaleHeight)
  839.     Me.PSet (X, Y), blue
  840. Next a
  841. End Sub
  842. Public Sub InitializePlanets()
  843. 'set properties that don't change
  844. Dim a As Integer
  845. For a = 0 To 49
  846.     Planet(a).Owner = Neutral     'default to neutral owner
  847.     Planet(a).Troops = 0
  848.     Planet(a).CombatStrength = 0
  849.     Planet(a).Resources = Int(Rnd * 4) + 1
  850.     Planet(a).Contaminated = False
  851.     Planet(a).HaveMissiles = False
  852.     Planet(a).HaveShields = False
  853.     Planet(a).ImprovedResources = False
  854.     Planet(a).HaveScanner = False
  855.     Planet(a).HaveJammer = False
  856.     Planet(a).Contaminated = False
  857.     Planet(a).NukedResources = False
  858.     Planet(a).Sabotaged = False
  859. Next a
  860. 'set up other fixed planet info
  861. 'Row One:
  862. With Planet(0)
  863.     .Name = "Regulon"
  864.     .Coordinate = "A1"
  865.     .BackGround = 1
  866. End With
  867. With Planet(1)
  868.     .Name = "Arcturus"
  869.     .Coordinate = "A1"
  870.     .BackGround = 2
  871. End With
  872. With Planet(2)
  873.     .Name = "Pertussis"
  874.     .Coordinate = "B1"
  875.     .BackGround = 3
  876. End With
  877. With Planet(3)
  878.     .Name = "Rigel IV"
  879.     .Coordinate = "B1"
  880.     .BackGround = 4
  881. End With
  882. With Planet(4)
  883.     .Name = "Peklon"
  884.     .Coordinate = "C1"
  885.     .BackGround = 5
  886. End With
  887. With Planet(5)
  888.     .Name = "Smeglor"
  889.     .Coordinate = "C1"
  890.     .BackGround = 4
  891. End With
  892. With Planet(6)
  893.     .Name = "Gabbo"
  894.     .Coordinate = "D1"
  895.     .BackGround = 3
  896. End With
  897. With Planet(7)
  898.     .Name = "Xerxex"
  899.     .Coordinate = "D1"
  900.     .BackGround = 2
  901. End With
  902. With Planet(8)
  903.     .Name = "Bulimus III"
  904.     .Coordinate = "E1"
  905.     .BackGround = 2
  906. End With
  907. With Planet(9)
  908.     .Name = "Irkutsk"
  909.     .Coordinate = "E1"
  910.     .BackGround = 1
  911. End With
  912. 'Setup Row Two:
  913. With Planet(10)
  914.     .Name = "Margulon"
  915.     .Coordinate = "A2"
  916.     .BackGround = 2
  917. End With
  918. With Planet(11)
  919.     .Name = "Zigurova"
  920.     .Coordinate = "A2"
  921.     .BackGround = 3
  922. End With
  923. With Planet(12)
  924.     .Name = "Plexus"
  925.     .Coordinate = "B2"
  926.     .BackGround = 4
  927. End With
  928. With Planet(13)
  929.     .Name = "Nexus"
  930.     .Coordinate = "B2"
  931.     .BackGround = 5
  932. End With
  933. With Planet(14)
  934.     .Name = "Plemptor"
  935.     .Coordinate = "C2"
  936.     .BackGround = 4
  937. End With
  938. With Planet(15)
  939.     .Name = "Melnos"
  940.     .Coordinate = "C2"
  941.     .BackGround = 3
  942. End With
  943. With Planet(16)
  944.     .Name = "Dorkasmia"
  945.     .Coordinate = "D2"
  946.     .BackGround = 2
  947. End With
  948. With Planet(17)
  949.     .Name = "Obesios"
  950.     .Coordinate = "D2"
  951.     .BackGround = 1
  952. End With
  953. With Planet(18)
  954.     .Name = "Klathax"
  955.     .Coordinate = "E2"
  956.     .BackGround = 2
  957. End With
  958. With Planet(19)
  959.     .Name = "Troomb"
  960.     .Coordinate = "E2"
  961.     .BackGround = 3
  962. End With
  963. With Planet(20)
  964.     .Name = "Phobos"
  965.     .Coordinate = "A3"
  966.     .BackGround = 4
  967. End With
  968. With Planet(21)
  969.     .Name = "Ebon"
  970.     .Coordinate = "A3"
  971.     .BackGround = 5
  972. End With
  973. With Planet(22)
  974.     .Name = "Orleska"
  975.     .Coordinate = "B3"
  976.     .BackGround = 4
  977. End With
  978. With Planet(23)
  979.     .Name = "Ginsana"
  980.     .Coordinate = "B3"
  981.     .BackGround = 3
  982. End With
  983. With Planet(24)
  984.     .Name = "Algathra"
  985.     .Coordinate = "C3"
  986.     .BackGround = 2
  987. End With
  988. With Planet(25)
  989.     .Name = "Mutalgon"
  990.     .Coordinate = "C3"
  991.     .BackGround = 1
  992. End With
  993. With Planet(26)
  994.     .Name = "Urkel V"
  995.     .Coordinate = "D3"
  996.     .BackGround = 2
  997. End With
  998. With Planet(27)
  999.     .Name = "Cortiska"
  1000.     .Coordinate = "D3"
  1001.     .BackGround = 3
  1002. End With
  1003. With Planet(28)
  1004.     .Name = "Gath"
  1005.     .Coordinate = "E3"
  1006.     .BackGround = 4
  1007. End With
  1008. With Planet(29)
  1009.     .Name = "Exevios"
  1010.     .Coordinate = "E3"
  1011.     .BackGround = 5
  1012. End With
  1013. With Planet(30)
  1014.     .Name = "Ektalbek"
  1015.     .Coordinate = "A3"
  1016.     .BackGround = 4
  1017. End With
  1018. With Planet(31)
  1019.     .Name = "Intebron"
  1020.     .Coordinate = "A4"
  1021.     .BackGround = 3
  1022. End With
  1023. With Planet(32)
  1024.     .Name = "Criegor"
  1025.     .Coordinate = "B4"
  1026.     .BackGround = 2
  1027. End With
  1028. With Planet(33)
  1029.     .Name = "Doolgas"
  1030.     .Coordinate = "B3"
  1031.     .BackGround = 1
  1032. End With
  1033. With Planet(34)
  1034.     .Name = "Ceti Alpha 5"
  1035.     .Coordinate = "C4"
  1036.     .BackGround = 2
  1037. End With
  1038. With Planet(35)
  1039.     .Name = "Alteides"
  1040.     .Coordinate = "C4"
  1041.     .BackGround = 3
  1042. End With
  1043. With Planet(36)
  1044.     .Name = "Baxterion"
  1045.     .Coordinate = "D4"
  1046.     .BackGround = 4
  1047. End With
  1048. With Planet(37)
  1049.     .Name = "Uilta"
  1050.     .Coordinate = "D4"
  1051.     .BackGround = 5
  1052. End With
  1053. With Planet(38)
  1054.     .Name = "Goothuzem"
  1055.     .Coordinate = "E4"
  1056.     .BackGround = 4
  1057. End With
  1058. With Planet(39)
  1059.     .Name = "Eidos"
  1060.     .Coordinate = "E4"
  1061.     .BackGround = 3
  1062. End With
  1063. With Planet(40)
  1064.     .Name = "Krupaxas"
  1065.     .Coordinate = "A5"
  1066.     .BackGround = 2
  1067. End With
  1068. With Planet(41)
  1069.     .Name = "Jyzynga"
  1070.     .Coordinate = "A5"
  1071.     .BackGround = 1
  1072. End With
  1073. With Planet(42)
  1074.     .Name = "Corella"
  1075.     .Coordinate = "B5"
  1076.     .BackGround = 2
  1077. End With
  1078. With Planet(43)
  1079.     .Name = "Madelos"
  1080.     .Coordinate = "B5"
  1081.     .BackGround = 3
  1082. End With
  1083. With Planet(44)
  1084.     .Name = "Zantar"
  1085.     .Coordinate = "C5"
  1086.     .BackGround = 4
  1087. End With
  1088. With Planet(45)
  1089.     .Name = "Solanas III"
  1090.     .Coordinate = "C5"
  1091.     .BackGround = 5
  1092. End With
  1093. With Planet(46)
  1094.     .Name = "Cerberus"
  1095.     .Coordinate = "D5"
  1096.     .BackGround = 4
  1097. End With
  1098. With Planet(47)
  1099.     .Name = "Remulak"
  1100.     .Coordinate = "D5"
  1101.     .BackGround = 3
  1102. End With
  1103. With Planet(48)
  1104.     .Name = "Volenti"
  1105.     .Coordinate = "E5"
  1106.     .BackGround = 2
  1107. End With
  1108. With Planet(49)
  1109.     .Name = "Rubika"
  1110.     .Coordinate = "E5"
  1111.     .BackGround = 1
  1112. End With
  1113. End Sub
  1114.